@extends('common.admin-master')

@section('html-body')
    <div class="content">

        <div class="header">
            <div class="stats">
                <p class="stat"><a href="{{route('Admin.Projects.editProjectByProjectId' ,['id'=>0])}}">添加项目</a></p>
                <p class="stat"><a href="{{route('Admin')}}">返回首页</a></p>
            </div>
            <h1 class="page-title">项目管理</h1>
        </div>

        <ul id="myTab" class="nav nav-tabs">
            <li class="active"><a href="#creater_list" data-toggle="tab">项目列表</a></li>
        </ul>

        <div class="container-fluid">
            <div class="row-fluid">
                <div class="row-fluid">
                    <div id="TabContent" class="tab-content">
                        <div class="tab-pane fade in active" id="creater_list">
                            <div class="row-fluid">
                                <div class="block span12">
                                    <a href="#tablewidget" class="block-heading" data-toggle="collapse">项目列表<span
                                                class="label label-warning">+{{count($projects)}}</span></a>
                                    <div id="tablewidget" class="block-body collapse in">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>项目名</th>
                                    <th>项目拥有者</th>
                                    <th>领域</th>
                                    <th>阶段</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @if($projects)
                                    @foreach($projects as $project)
                                        <tr>
                                            <td>{{$project->project_name}}</td>
                                            <td>
                                                @if($project->toUser)
                                                    @if($project->toUser->userInfo)
                                                    {{$project->toUser->userInfo->realname}}
                                                    @endif
                                                @else
                                                    暂无数据
                                                @endif
                                            </td>
                                            <td>
                                                @if($fields = $project->project_x_fields)
                                                    @foreach($fields as $field)
                                                        @if($field)
                                                            <em>{{$field->field}}</em>
                                                        @else
                                                            <em>暂无数据</em>
                                                        @endif
                                                    @endforeach
                                                @else
                                                    暂无数据
                                                @endif
                                            </td>
                                            <td>
                                                @if($project->toPhase)
                                                    {{$project->toPhase->phase}}
                                                @else
                                                    暂无数据
                                                @endif
                                            </td>
                                            <td>
                                                @if($project->create_time)
                                                    {{date('Y-m',strtotime($project->create_time))}}</td>
                                                @else
                                                    {{date('Y-m',strtotime($project->created_at))}}
                                                @endif
                                            <td>
                                                <a class="del" href="{{route('Admin.Projects.editProjectByProjectId' ,['id'=>$project->id])}}">编辑</a>
                                                <a class="del" href="javascript:;" data="{{$project->id}}">删除</a>
                                            </td>
                                        </tr>
                                    @endforeach
                                @endif
                                </tbody>
                            </table>
                        </div>
                        <div class="pagination">
                            <ul>
                                {!! $projects->render() !!}
                            </ul>
                        </div>
                    </div>

                </div>



    <script type="text/javascript">
        $("[rel=tooltip]").tooltip();
        $(function() {
            $('.demo-cancel-click').click(function(){return false;});
        });

        $('#nav_tab a').click(function (e) {
            e.preventDefault();
            $(this).tab('show');
        })

    </script>
    <script>
        var DeleteProjectById   =   "{{route('Api.Admin.DeleteProjectById')}}";
    </script>
    <script src="{{url('js/admin/project.js')}}"></script>

@endsection


